#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：    zhuifeng_index.py
   Author :       zyq
   CreateDate：   2024/7/12 15:25
   Remark :  Python descriptor
-------------------------------------------------
"""
import time

import allure

# from page_object.zhuifeng_pages import page_object, PageElement

from guitesting.common.bash.bash_ui.page_element import PageElement
from guitesting.common.bash.bash_ui.base_page import BasePage


class ZhuiFengLoginPage(BasePage):
    """
    将描述符的实例化赋值给当前类的属性。这个属性就是实例化

    page_object: 它的作为只是
    """
    # 自动设置每一个页面选择器，自动给操作对象使用，无法手动赋值
    input_account = PageElement(xpath='/html/body/section/main/div/div[2]/div/form/div[1]/div/div/input')
    input_password = PageElement(xpath='/html/body/section/main/div/div[2]/div/form/div[2]/div/div/input')
    auto_code = PageElement(xpath='/html/body/section/main/div/div[2]/div/form/div[3]/div/div/input')
    log_in_button = PageElement(xpath='/html/body/section/main/div/div[2]/div/form/div[4]/div/button[1]')
    image = PageElement(id='code')
    image_code = PageElement(xpath='/html/body/section/main/div/div[2]/div/form/div[3]/div/div/input')

    # ===========================================================================
    # ============================= 定义业务步骤方法 =================================
    # ===========================================================================

    @allure.step('输入账号密码')
    def enter_credentials(self, login_username, login_password) -> None:
        self.input_account = login_username
        self.input_password = login_password


    @allure.step('输入验证码')
    def enter_image_code(self) -> None:
        self.image_code = self.image.image_ocr_identify()

    @allure.step('点击登录按钮')
    def click_log_in(self) -> None:
        self.log_in_button.click_element()
        time.sleep(2)

